﻿using System;
using System.Collections.Generic;

namespace TradeHelp.Utilities
{
    /// <summary>
    /// 
    /// </summary>
    public static class RandomHelper
    {
        private static readonly Random _random = new Random(DateTime.Now.Millisecond);

        /// <summary>
        /// 
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="list"></param>
        /// <returns></returns>
        public static T GetRandom<T>(this IList<T> list)
        {
            return list[_random.Next(0, list.Count)];
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="min"></param>
        /// <param name="max"></param>
        /// <returns></returns>
        public static int GetRandom(int min, int max)
        {
            return _random.Next(min, max);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="max"></param>
        /// <returns></returns>
        public static int GetRandom(int max)
        {
            return _random.Next(max);
        }
    }
}